package com.work.crops.dao;

import com.work.crops.pojo.CropsInfo;
import com.work.crops.pojo.CropsInfoIndex;
import com.work.crops.pojo.CropsParam;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;

public interface CropsInfoIndexMapper extends Mapper<CropsInfoIndex> {

     @Select("DELETE FROM `t_crops_info_index` WHERE cid = #{id}")
    Integer findCropsInfoIndexByCid(String id);


     @Select("<script>" +
             "SELECT * FROM t_crops_info_index " +
             "<if test=\"empty != 'alin' \">" +
             "<where> " +
             "<if test=\"stage != null and stage != ''\"> stage = #{stage} </if>\" " +
             " <if test=\"region != null and region != ''\"> and region = #{region}</if>\"   " +
             "</where>" +
             "</if>" +
             "</script>")
    List<CropsInfoIndex> findByPage(CropsParam cropsParam);


//     根据农作物id查询数据指标
     @Select("select * from t_crops_info_index where cid = #{id} and stage = #{stage}")
     List<CropsInfoIndex> findByCropsId(@Param("id") Integer id, @Param("stage") String stage);
}
